package com.zs.propertymanage.service.impl.impl;

import com.zs.propertymanage.dataObj.DTO;
import com.zs.propertymanage.dataObj.R;
import com.zs.propertymanage.dataObj.entity.Message;
import com.zs.propertymanage.mapper.MessageMapper;
import com.zs.propertymanage.service.impl.MessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MessageServiceImpl implements MessageService {

    @Autowired
    private MessageMapper messageMapper;

    @Override
    public R getMessages(Integer receiverType, String receiverId) {
        List<Message> messages = messageMapper.getMessages(receiverType, receiverId);
        return messages.size() > 0 ? R.ok("获取消息列表成功", new DTO<>(messages, messages.size())) : R.error("暂未获取到消息");
    }
}
